package com.yenroc.ho.transaction;

import com.yenroc.ho.netty.enums.GlobalTransactionType;

import java.util.UUID;

/**
 * @author： heyanpeng
 * @date： 2021/7/27
 */
public class GlobalTransactionInfo {

    private String groupId;

    private String transactionId;

    private final TkLock task;

    private GlobalTransactionType type;

    public GlobalTransactionInfo(String groupId){
        this.groupId = groupId;
        transactionId = UUID.randomUUID().toString();
        task = new TkLock();
    }

    /**
     * 业务相关资源
     */
    private Object resource;

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getTransactionId() {
        return transactionId;
    }


    public TkLock getTask() {
        return task;
    }

    public Object getResource() {
        return resource;
    }

    public void setResource(Object resource) {
        this.resource = resource;
    }

    public GlobalTransactionType getType() {
        return type;
    }

    public void setType(GlobalTransactionType type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "GlobalTransaction{" +
                "groupId='" + groupId + '\'' +
                ", transactionId='" + transactionId + '\'' +
                '}';
    }
}
